package net.neptech.model.schedule;

import com.fasterxml.jackson.annotation.JsonFormat;
import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import net.neptech.utils.SnowflakeIdGenerator;
import org.hibernate.annotations.GenericGenerator;
import org.springframework.format.annotation.DateTimeFormat;

import java.io.Serial;
import java.io.Serializable;
import java.util.Date;
/**
 * @Author HuangZhengmin
 * @desc  排班表实体类
 * @Date 2025/8/12 17:26
 * @Version 1.0
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
@Entity
@Table(name = "schedule")
public class Schedule implements Serializable {
    @Serial
    private static final Long serialVersionUID = 1L;

  @Id
  @GenericGenerator(name = "snowflake", type = SnowflakeIdGenerator.class)
  @GeneratedValue(generator = "snowflake")
  @Column(name = "schedule_id", nullable = false)
  private Long scheduleId; // 排班ID

  @Column(name = "staff_id")
  private Long staffId; // 被排班人员id

  @Column(name = "staff_name")
  private String staffName; // 被排班人员姓名

  @Column(name = "duty_day")
  @DateTimeFormat(pattern = "yyyy-MM-dd")
  @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
  private Date dutyDay; // 值班日期

  @ManyToOne  // 多对一关联
  @JoinColumn(name = "shift_id", referencedColumnName = "shift_id", insertable = false, updatable = false)
  private ScheShift scheShift; // 关联的班次信息

  @Column(name = "shift_id")
  private Long shiftId; // 班次ID

  @Column(name = "dept_id")
  private Long deptId; // 执行该班次的科室ID

  @Column(name = "status")
  private Integer status = 1; // 状态(0-特殊情况未正常执行,1-正常执行)

  @Column(name = "manager_name")
  private String managerName; // 创建人，科室负责人

  @Column(name = "create_time")
  @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
  @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
  private Date createTime; // 创建时间

  @Column(name = "update_time")
  @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
  @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
  private Date updateTime; // 更新时间
}
